package zhieasy.cn.xpu_helper.controller.initiation;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import zhieasy.cn.common.utils.ResultVOUtil;
import zhieasy.cn.common.vo.ResultVO;
import zhieasy.cn.model.common.Major;
import zhieasy.cn.model.common.StudentUser;
import zhieasy.cn.service.initiation.CollegeInfoService;
import zhieasy.cn.service.initiation.TeacherService;

import java.util.List;
import java.util.Map;

/**
 * @author sofency
 * @date 2020/8/21 22:11
 * @package IntelliJ IDEA
 * @description
 */
@Api(tags = "开学地图,教师端的api")
@RestController
@RequestMapping("/initiation")
public class TeacherController {

    @Autowired
    CollegeInfoService collegeInfoService;

    @Autowired
    TeacherService teacherService;

    /**
     * 获取专业的列表
     */
    @ApiOperation(value="根据学院的id获取专业列表",notes = "根据学院的id 获取专业的列表")
    @GetMapping("/majors")
    public ResultVO<List<Major>> getMajorList(@ApiParam("学院的id") String collegeId){
        List<Major> majors = collegeInfoService.getMajors(collegeId);
        return ResultVOUtil.success(majors);
    }

    /**
     * 到校获取专业对应的班级对应的数组列表
     * @param majorId
     * @return
     */
    @ApiOperation(value="到校专业对应的班级数组列表",notes = "到校专业对应的班级数组列表")
        @GetMapping("/comeSchool")
        public ResultVO<Map<String,Object>> getStudentList(@ApiParam("专业的id")
                                                               @RequestParam(required = false,defaultValue = "") String majorId){
            Map<String, Object> comeToSchoolDetails = teacherService.getComeToSchoolDetails(majorId);
            return ResultVOUtil.success(comeToSchoolDetails);
    }

    /**
     * 报名完成的班级和对应的数组列表
     * @param majorId
     * @return
     */
    @ApiOperation(value = "报名完成对应的班级的数组列表",notes = "报名完成对应的班级的数组列表")
    @GetMapping("/signSuccess")
    public ResultVO<Map<String,Object>> getSignedList(@ApiParam("专业的id") @RequestParam(required = false,defaultValue = "") String majorId){
        Map<String, Object> signed = teacherService.getSigned(majorId);
        return ResultVOUtil.success(signed);
    }

    /**
     * 报名完成的班级和对应的数组列表
     * @param gradeId
     * @param flag
     * @return
     */
    @ApiOperation(value = "获取班级的详细信息",notes = "获取班级的详细信息")
    @GetMapping("/gradeDetail")
    public ResultVO<Map<String,Object>> getGradeDetail(@ApiParam("班级的id") String gradeId,
                                                       @ApiParam("到校还是未到校") Boolean flag){
        Map<String, Object> studentToSchool = teacherService.getStudentToSchool(gradeId, flag);
        return ResultVOUtil.success(studentToSchool);
    }


    /**
     * 报名完成的班级和对应的数组列表
     * @return
     */
    //获取用户的信息
    @ApiOperation(value = "学生的用户信息",notes = "学生的用户信息")
    @GetMapping("/studentDetail")
    public ResultVO<StudentUser> getStudentDetail(){
        StudentUser studentDetail = teacherService.getStudentDetail();
        return ResultVOUtil.success(studentDetail);
    }

}
